package algorithms.paixu.test;



import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.UUID;

/**
 * @功能
 * @创建时间 2021/2/22
 */
public class SortOne {
    public static void main(String[] args) {
        Stack<Integer> arr1;
        Stack<Integer> fiarr2ns1;



    }
    public static boolean sort( Stack<Integer> arr1 ,Stack<Integer> arr2){
        Stack<Integer> arred = null;
        if (arr1.isEmpty() && arr2.isEmpty())
            return false;
        while (arr1.size() > 0 && arr2.size() > 0){
          if(arr1.peek() < arr2.peek()){
              arred.push(arr1.pop());
          }else {
              arred.push(arr2.pop());
          }
        }
        while (arr1.size() > 0 && arr2.size() == 0){
            arred.push(arr1.pop());
        }
        while (arr1.size() == 0 && arr2.size() > 0){
            arred.push(arr2.pop());
        }
        return true;
    }

    public static void change(List<Fins> fins){
        for (int i = 0; i < fins.size() ; i++) {
            findMin(fins,i);
        }

    }


    public static void findMin(List<Fins> fins, Integer t){
        for (int i = fins.size(); i > t; i--) {
            if(fins.get(i-1).getSum()<fins.get(i).getSum()){
                sort(fins,i,i-1);
            }
           if(t==1){
               fins.get(0).setRank(1);
           }
           else if(fins.get(t-1).getSum()==fins.get(t-2).getSum()){
               fins.get(t-1).setRank(fins.get(t-2).getRank());
           }
           else {
               fins.get(t-1).setRank(fins.get(t-2).getRank()+1);
           }
        }
    }


    public static void sort(List<Fins> fins,Integer rankma, Integer rankmi){
       Fins a=fins.get(rankma);
       fins.set(rankma,fins.get(rankmi));
       fins.set(rankmi,a);
    }
}
